<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="../../0505/js/jq.js"></script>
    <script>
        let p = (url)=>{
            return new Promise((resolve, reject) => {
                $.ajax({
                    url: url,
                    success(res) {
                        resolve(res);
                    },
                    error(err) {
                        reject(err)
                    }
                })
            })
        }
        let p1 = p('http://localhost:3000/play/hot');
        let p2 = p('http://localhost:3000/play/category');

        // all 接受所有数据
        Promise.all([p1, p2])
        .then(res => {
            let [res1, res2] = res; // 数组解构
            console.log(res1);
            console.log(res2);
        })

        // race
        Promise.race([p1, p2])
        .then(res => {
            console.log(111, res);
        })
    </script>
</body>
</html>